import 'package:boss/color_constant.dart';
import 'package:boss/textStyle/text_style.dart';
import 'package:boss/ui/widget/split_line.dart';
import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';

class BillOffersPanel extends StatelessWidget {
  final String title;
  final int leftAmount;
  final int centerAmount;
  final int rightAmount;
  final String leftTitle;
  final String centerTitle;
  final String rightTitle;

  const BillOffersPanel({
    @required this.title,
    @required this.leftAmount,
    @required this.centerAmount,
    @required this.rightAmount,
    @required this.leftTitle,
    @required this.centerTitle,
    @required this.rightTitle,
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 230.w,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(
          14.w,
        ),
        gradient: LinearGradient(
          begin: Alignment.centerLeft,
          end: Alignment.centerRight,
          colors: [
           ColorConstant.f5054f6,
            ColorConstant.f5870f6,
          ],
        ),
      ),
      margin: EdgeInsets.only(
        top: 30.w,
      ),
      padding: EdgeInsets.only(
        top: 30.w,
        bottom: 40.w,
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: <Widget>[
          Container(
            padding: EdgeInsets.symmetric(horizontal: 30.w),
            child: Text(
              title,
              style: TextStyleConstant().white_28,
            ),
          ),
          Row(
            children: <Widget>[
              _Offers(
                price: leftAmount,
                title: leftTitle,
              ),
              SplitLine(),
              _Offers(
                price: centerAmount,
                title: centerTitle,
              ),
              SplitLine(),
              _Offers(
                price: rightAmount,
                title: rightTitle,
              ),
            ],
          ),
        ],
      ),
    );
  }
}

class _Offers extends StatelessWidget {
  final int price;
  final String title;

  const _Offers({
    Key key,
    this.price,
    this.title,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Expanded(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Text(
            AmountUtil.price2String(price),
            style: TextStyleConstant().white_40.copyWith(
                  fontFamily: 'DINAlternate-Bold',
                ),
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
          ),
          Container(
            margin: EdgeInsets.only(
              top: 10.w,
            ),
            child: RichText(
              text: TextSpan(
                text: title,
                style: TextStyle(
                  fontSize: 24.sp,
                  color: Color.fromRGBO(255, 255, 255, .8),
                ),
                children: [
                  TextSpan(
                    text: '/',
                    style: TextStyleConstant().white_22,
                  ),
                  TextSpan(
                    text: '元',
                    style: TextStyleConstant().yellow_22,
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
    );
  }
}
